package com.example.web.sys_role_menu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.web.sys_role.entity.SaveMenuParam;
import com.example.web.sys_role_menu.entity.RoleMenu;
import com.example.web.sys_role_menu.mapper.RoleMenuMapper;
import com.example.web.sys_role_menu.service.IRoleMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LS
 * @since 2024-02-21
 */
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService {
    @Override
    @Transactional
    public void saveRoleMenu(SaveMenuParam param) {
        //先删除
        QueryWrapper<RoleMenu> query = new QueryWrapper<>();
        query.lambda().eq(RoleMenu::getRoleId,param.getRoleId());
        this.baseMapper.delete(query);
        //再保存
        this.baseMapper.saveRoleMenu(param.getRoleId(),param.getList());
    }

}
